package com.kaiwukj.android.ufamily.mvp.ui.page.service.community;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.CommunityNewResult;

import org.jetbrains.annotations.NotNull;

public class CommunityNewAdapter extends BaseQuickAdapter<CommunityNewResult, BaseViewHolder> {
    public CommunityNewAdapter() {
        super(R.layout.item_community_news);
    }

    @Override
    public long getItemId(int position) {
        return getItem(position) == null ? -1 : getItem(position).getId();
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, CommunityNewResult communityNewResult) {
        Glide.with(getContext())
                .load(communityNewResult.getThumbnail())
                .centerCrop()
                .into((ImageView) holder.getView(R.id.image));
        holder.setText(R.id.tv_author, communityNewResult.getPublisher());
        holder.setText(R.id.tv_create_time, communityNewResult.getCreateTime());
    }
}
